<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <script src="/js/jquery.min.js" type="text/javascript"></script>
<style>
  body {
    font-size: 12px;
  }

  #msg {
    color: red;
  }

  input {
    background-color: #F8FCFE;
    border: #D6EDF8 solid 1px;

  }
  </style>
  <script>
    //上传完成后调用方法
    function imgUploadSucceed(name, path, w, h) {
      parent.imgUploadSucceed(name, path, w, h);
      $("#imgurl").val(path);
      $("#imgw").val(w);
      $("#imgh").val(h);
      $("#msg").html("<font color=red>图片上传成功</font>");

    }
    //上传失败调用方法
    function imgUploadFail(error) {
      $("#msg").html(error);
    }
    function beginUp()
    {

      if ($("#file")[0].value == "")
      {
        alert("上传文件不能为空");
        return false;
      }
      $("#msg").html("<img src='/images/up.gif' border='0'/>");
    }
    //高级图片处理工具
    function dealImg() {
       if ($("#imgurl")[0].value == "")
      {
        alert("请先上传图片后再使用图片处理工具。");
        return false;
      }
      window.open('/share/imgCrop.gsp?w=${params.w}&h=${params.h}&imgurl=' + $("#imgurl")[0].value+'&imgw='+ $("#imgw")[0].value+'&imgh='+$("#imgh")[0].value, 'newwindow', 'height=400, width=850,  toolbar=no, menubar=no, scrollbars=no, location=n o, status=no') //这句要写成一行
    }
    //裁剪完成后调用方法
    function imgCropSucceed(path){
         parent.imgCropSucceed(path);
    }
  </script>
</head>
<body>
<form action="/upload/img" id="myUploadFileForm" name="myUploadFileForm" encType="multipart/form-data" method="post" target="hidden_frame" onSubmit="return beginUp();">
  <input type="file" id="file" name="file" style="width:250px">
  <input type="submit" value="上传图片"> <input type="button" name="crop" id="crop" value="高级图片处理工具" onclick="dealImg();"/>
  <br>
  <iframe name='hidden_frame' id="hidden_frame" style='display:none'></iframe> <span id="msg"></span>
</form>
<input type="hidden" name="imgurl" id="imgurl">
<input type="hidden" name="imgw" id="imgw">
<input type="hidden" name="imgh" id="imgh">
</body>
</html>
